import { Loading as ElLoading } from 'element-ui'

let _loadingInstance: any

/**
 * 显示loading
 */
export const showLoading = (
  options: any = {
    body: true,
    fullscreen: true,
    lock: true,
  }
) => {
  if (!_loadingInstance) {
    _loadingInstance = ElLoading.service(options)
  }
}

/**
 * 关闭loading
 */
export const closeLoading = () => {
  if (_loadingInstance) {
    _loadingInstance.close()
    _loadingInstance = null
  }
}
